1. Tips: 省略屬性名稱

當物件的屬性與函式/變數名稱相同時,可以省略不寫 !!!

// 原本的寫法
const view = {
  displayCards: function displayCards() { ...  }
}
// 省略後的寫法
const view = {
  displayCards() { ...  }
}

2. 解構賦值 destructuring assignment

let [a, b, c] = [1, 2, 3]
只要等號兩邊的模式相同 (例如都是 [] 或都是 {}),左邊的變數就會被賦予右邊的對應值。


#省略屬性名稱 #解構賦值 destructuring assignment







Related Posts

[Web] 轉換 [icon svg] 為 [background-image]

[Web] 轉換 [icon svg] 為 [background-image]

資結、 Complexity and Big O Notation

資結、 Complexity and Big O Notation

AWS Solutions Architect - Associate (SAA) 學習計畫與備考心得: Module 2

AWS Solutions Architect - Associate (SAA) 學習計畫與備考心得: Module 2


Comments